#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 6010;

int n, x, y;
char a[N], b[N];
int q[N], tt;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int T;
    scanf("%d", &T);
    while(T--){
        scanf("%d%d%d", &n, &x, &y);
        scanf("%s%s", a + 1, b + 1);
        tt = 0;
        for(int i = 1; i <= n; i ++){
            if(a[i] != b[i]){
                q[tt++] = i;
            }
        }

        if(tt % 2){
            printf("-1\n");
            continue;
        }

        if(tt == 2){
            if(q[1] - q[0] == 1){   
                int res = min(y * 2, x);
                printf("%d\n", res);
            }else{
                printf("%d\n", y);
            }
        }else{
            printf("%lld\n", (LL)tt / 2 * y);
        }

    }

    return 0;
}